package com.lehecai.core.api.credit;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by zhangzq on 14-3-5.
 */
public class DeliveryType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(DeliveryType.class.getName());
    private static final long serialVersionUID = -1;

    private static List<DeliveryType> _items = new ArrayList<DeliveryType>();
    private static List<DeliveryType> items;

    protected DeliveryType(String name, int value) {
        super(DeliveryType.class.getName(), name, value);
        _items.add(this);
    }

    public static DeliveryType getItem(int value){
        try {
            return (DeliveryType) DeliveryType.getResult(DeliveryType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    /**
     * @return
     */
    public static List<DeliveryType> getItems() {
        return items;
    }
    public static final DeliveryType ALL = new DeliveryType("全部", -1);
    public static final DeliveryType DELIVERY_AUTOMATIC = new DeliveryType("自动发货", 1);
    public static final DeliveryType DELIVERY_FAST = new DeliveryType("快递", 2);

    static {
        synchronized (_items) {
            items = Collections.unmodifiableList(_items);
        }
    }
}
